﻿#ifndef ATTITUDEINDICATOR_H
#define ATTITUDEINDICATOR_H

#include <QWidget>
#include <QPainterPath>
#include <QtMath>

/**
 * @brief The AttitudeIndicator class
 * 飞机仪表盘控件
 */
class AttitudeIndicator : public QWidget

{
    Q_PROPERTY(QColor borderOutColorStart READ getBorderOutColorStart WRITE setBorderOutColorStart)
    Q_PROPERTY(QColor borderOutColorEnd READ getBorderOutColorEnd WRITE setBorderOutColorEnd)
    Q_PROPERTY(QColor borderInColorStart READ getBorderInColorStart WRITE setBorderInColorStart)
    Q_PROPERTY(QColor borderInColorEnd READ getBorderInColorEnd WRITE setBorderInColorEnd)

    Q_PROPERTY(QColor bgUpperColor READ getBgUpperColor WRITE setBgUpperColor)
    Q_PROPERTY(QColor bgLowerColor READ getBgLowerColor WRITE setBgLowerColor)
    Q_PROPERTY(QColor glassColor READ getGlassColor WRITE setGlassColor)
    Q_PROPERTY(QColor scaleColor READ getScaleColor WRITE setScaleColor)
    Q_PROPERTY(QColor lineColor READ getLineColor WRITE setLineColor)
    Q_PROPERTY(QColor textColor READ getTextColor WRITE setTextColor)
    Q_PROPERTY(QColor pointerColor READ getPointerColor WRITE setPointerColor)
    Q_PROPERTY(QColor handleColor READ getHandleColor WRITE setHandleColor)

    Q_PROPERTY(float rollValue READ getRollValue WRITE setRollValue)
    Q_PROPERTY(float pitchValue READ getPitchValue WRITE setPitchValue)
    Q_PROPERTY(float yawValue READ getYawValue WRITE setYawValue)

public:
    explicit AttitudeIndicator(QWidget *parent = 0);

protected:
    void paintEvent(QPaintEvent *);
    void drawBorderOut(QPainter *painter);
    void drawBg(QPainter *painter);
    void drawBgOut(QPainter *painter);
    void drawPlane(QPainter *painter);
    void drawGlass(QPainter *painter);
    void drawScale(QPainter *painter);
    void drawLine(QPainter *painter);
    void drawPointer(QPainter *painter);
    void drawHandle(QPainter *painter);
    void drawScaleOut(QPainter *painter);
    void drawScaleOutNum(QPainter *painter);
    void drawPointerOut(QPainter *painter);

private:
    QColor borderOutColorStart;     //外边框渐变开始颜色
    QColor borderOutColorEnd;       //外边框渐变结束颜色
    QColor borderInColorStart;      //里边框渐变开始颜色
    QColor borderInColorEnd;        //里边框渐变结束颜色

    QColor bgUpperColor;            //背景上颜色
    QColor bgLowerColor;            //背景下颜色
    QColor bgOutColor;              //外侧黑色背景颜色
    QColor glassColor;              //遮罩层颜色
    QColor scaleColor;              //刻度尺颜色
    QColor lineColor;               //线条颜色
    QColor textColor;               //文字颜色
    QColor pointerColor;            //指针颜色
    QColor pointerOutColor;         //指针颜色2
    QColor handleColor;             //手柄颜色
    QColor darkColor;               //加深颜色
    QColor lightColor;              //明亮颜色
    QColor foreground;              //前景色

    float rollValue;                   //旋转角度
    float pitchValue;                  //滚动值
    float yawValue;

public:
    QColor getBorderOutColorStart() const;
    QColor getBorderOutColorEnd()   const;
    QColor getBorderInColorStart()  const;
    QColor getBorderInColorEnd()    const;

    QColor getBgUpperColor()        const;
    QColor getBgLowerColor()        const;
    QColor getGlassColor()          const;
    QColor getScaleColor()          const;
    QColor getLineColor()           const;
    QColor getTextColor()           const;
    QColor getPointerColor()        const;
    QColor getHandleColor()         const;

    float getRollValue()               const;
    float getPitchValue()              const;
    float getYawValue()                const;

    QSize sizeHint()                const;
    QSize minimumSizeHint()         const;

public Q_SLOTS:
    //设置外边框渐变颜色
    void setBorderOutColorStart(const QColor &borderOutColorStart);
    void setBorderOutColorEnd(const QColor &borderOutColorEnd);

    //设置里边框渐变颜色
    void setBorderInColorStart(const QColor &borderInColorStart);
    void setBorderInColorEnd(const QColor &borderInColorEnd);

    void setBgUpperColor(const QColor &bgUpperColor);
    void setBgLowerColor(const QColor &bgLowerColor);

    //设置遮罩层颜色
    void setGlassColor(const QColor &glassColor);

    //设置刻度尺颜色
    void setScaleColor(const QColor &scaleColor);

    //设置线条颜色
    void setLineColor(const QColor &lineColor);

    //设置文字颜色
    void setTextColor(const QColor &textColor);

    //设置指针颜色
    void setPointerColor(const QColor &pointerColor);

    //设置手柄颜色
    void setHandleColor(const QColor &handleColor);

    void setRollValue(float rollValue);
    void setPitchValue(float pitchValue);
    void setYawValue(float yawValue);
};

#endif // ATTITUDEINDICATOR_H
